Skip to content

Propagate read-only metadata to the Thing Description.#262

Merged
rwb27 merged 4 commits intomainfrom
readonly-metadata
Feb 26, 2026
Merged

Propagate read-only metadata to the Thing Description.#262
rwb27 merged 4 commits intomainfrom
readonly-metadata

Conversation

@rwb27
Copy link
Copy Markdown
Collaborator

@rwb27 rwb27 commented Feb 25, 2026

This adds readOnly and writeOnly into the PropertyAffordance that's returned as part of the Thing Description. It includes a test for that.

It also fixes a bug in ThingClient where read-only properties were non-data descriptors, which meant they could be written to (but would then be functioning as local variables and not talking to the server). We previously fixed #165 for DirectThingClient, this is effectively the same bug but on ThingClient.

Closes #259

@barecheck
Copy link
Copy Markdown

barecheck bot commented Feb 25, 2026

Barecheck - Code coverage report

Total: 96.43%

Your code coverage diff: -0.09% ▾

Uncovered files and lines
FileLines
src/labthings_fastapi/client/__init__.py62, 65-66, 177, 249-252, 359, 363, 368, 459
src/labthings_fastapi/properties.py695, 699, 722-725, 797, 816, 1025

Copy link
Copy Markdown
Contributor

@julianstirling julianstirling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this, but I'll let you check my commit.

I've changed some lines in test_thing_client that I think were intended to be `assert` statements: it now makes more sense.
The test still passes, but should now be more sensitive.

I also spotted a couple of minor typos in a docstring and an error.
@rwb27 rwb27 force-pushed the readonly-metadata branch from 4aab6db to b1a7db9 Compare February 25, 2026 21:22
Write-only properties are, in theory, supported in the client but not the server. This commit adds a test with a mocked Thing Description featuring a write-only property, and verifies the client behaves correctly.

I also swapped "Method not allowed" for a more descriptive error for read/write-only properties.
@rwb27 rwb27 added this to the v0.0.15 milestone Feb 25, 2026
@rwb27 rwb27 merged commit 31c06ec into main Feb 26, 2026
13 of 14 checks passed
@rwb27 rwb27 deleted the readonly-metadata branch February 26, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read Only properties don't set readOnly to true in thing description DirectThingClient silently breaks when read-only properties are written to.

2 participants